
package com.joysuch.wwyt.edu.enums;

/**
 * 参与考试状态
 *
 */
public enum TakeExamStates {

    NOT_STARTED(0, "未开始"), INPROGRESSING(1, "进行中"), PASSED(2, "考试通过"), NOT_PASSED(3, "未通过"), OUT_OF_DATE(4, "过期")
    , TO_BE_MARKED(5, "待阅卷");

    private int id;
    private String name;

    private TakeExamStates(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static TakeExamStates findByName(String name) {
        TakeExamStates[] values = TakeExamStates.values();
        for (TakeExamStates v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static TakeExamStates findById(Integer level) {
        TakeExamStates[] values = TakeExamStates.values();
        for (TakeExamStates v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer id) {
        if (id == null) {
            return null;
        }
        TakeExamStates[] values = TakeExamStates.values();
        for (TakeExamStates v : values) {
            if (v.getId() == id) {
                return v.getName();
            }
        }
        return null;
    }
}
